// page/coachs/message/index.js
Page({
    data: {
        isHide: 0,
        navIndex: 2,
        msg: {
            icon: "/images/icon/nodata.png",
            desc: "暂无消息"
        },
        topTabItems: ["新的学员", "试车学员", "学员预约"],
        currentTopItem: 0,
        notice: []
    },
    onLoad: function (options) {
        var that = this
        that.setData({
            isHide: 1,
            newStudent: [
                { date: "前天 9:00", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" }
            ],
            testStudent: [
                { date: "前天 9:00", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" }
            ],
            orderStudent: [
                { date: "前天 9:00", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" },
                { date: "2017-12-21 13:12", title: "您有新的学员啦！", content: "李达达报名了驾校特惠班（C1）成为了您的 学员，请前往查看。" }
            ]
        })
        that.setData({
            notice: that.data.newStudent
        })
    },
    showContent: function (e) {
        var that = this
        var idx = e.currentTarget.dataset.id
        var notice = that.data.notice
        notice[idx].show = !notice[idx].show
        that.setData({
            notice: notice
        })
    },
    //切换顶部标签
    switchTab: function (e) {
        var idx = e.currentTarget.dataset.idx
        this.setData({
            currentTopItem: idx
        })
        this.switchItems(idx)
    },
    //swiperChange
    bindChange: function (e) {
        var idx = e.detail.current
        this.setData({
            currentTopItem: idx
        })
        this.switchItems(idx)
    },
    switchItems: function (index) {
        wx.showLoading({
            title: '正在加载',
        })
        if (index == 0) {
            //新的学员
            this.setData({
                notice: this.data.newStudent
            })
        } else if(index == 1){
            //试车学员
            this.setData({
                notice: this.data.testStudent
            })
        }else{
            //学员预约
            this.setData({
                notice: this.data.orderStudent
            })           
        }
        wx.hideLoading()
    },
})